package com.jc.service.common.util;

import java.io.Serializable;

public class ResponseResult<T> implements Serializable {

    public static final int SUCCESS_CODE = 0;
    private static final long serialVersionUID = 1L;


    private int code;
    private String msg;
    private T data;
    
    public ResponseResult() {
    }
    
    public ResponseResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    
    public ResponseResult(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    
    public static <T> ResponseResult<T> success() {
        return new ResponseResult<>(SUCCESS_CODE, "操作成功");
    }
    
    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<>(SUCCESS_CODE, "操作成功", data);
    }
    
    public static <T> ResponseResult<T> success(String msg, T data) {
        return new ResponseResult<>(0, msg, data);
    }
    
    public static <T> ResponseResult<T> error(int code, String msg) {
        return new ResponseResult<>(code, msg);
    }
    
    public static <T> ResponseResult<T> error(int code, String msg, T data) {
        return new ResponseResult<>(code, msg, data);
    }
    
    public int getCode() {
        return code;
    }
    
    public void setCode(int code) {
        this.code = code;
    }
    
    public String getMsg() {
        return msg;
    }
    
    public void setMsg(String msg) {
        this.msg = msg;
    }
    
    public T getData() {
        return data;
    }
    
    public void setData(T data) {
        this.data = data;
    }
}